package com.cmcc.pcap.voltePcapParse.pcap;



/**
 * 常用协议类型值
 * @author starfish
 *
 */
public enum FrameType {
	
	ARP("0X0806","ARP"), 				 
	PUP("0X0200","PUP"), 					 
	RARP("0X8035","RARP"),					 
	IPv6("0X86DD","IPv6"),
	IPv4("0x0800","IPv4"),
	PPPoE("0X8863/0X8864","PPPoE"),
	MPLS("0X8847/0X8848","MPLS"),
	IPX("0x8137","IPX"),
	SPX("0x8137","IPX"),
	LSIS("0x8000","LSIS"),
	LACP("0x8809","LACP"),
	QVirtualLan("0x8100","802.1Q Virtual LAN");
	private String type;
	
	private String name;
	
	public String getType() {
		return type;
	}
	
	public void setType(String type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	public static String getFrameType(String args){
		for(FrameType frameType : FrameType.values()){
			if(frameType.getType().equals(args)){
				return frameType.getType();
			}else if(frameType.getName().equals(args)){
				return frameType.getType();
			}
		}
		return null;
	}
	
	public static FrameType getFrameType(short type){
		for(FrameType frameType : FrameType.values()){
			if(frameType.getType().equals(Short.toString(type))){
				return frameType;
			}
		}
		return null;
	}
	
   public static String getName(String type) {  
        for (FrameType c : FrameType.values()) {  
            if (type.equals(c.getType())) {  
                return c.name;  
            }  
        }  
        return null;  
    }  
 
	private FrameType(String type,String name) {
		this.type = type;
		this.name = name;
	}
	public static void main(String[] args) {
		getFrameType("0x0800");
		System.out.println(getName("0x0800"));
	}
	
}
